﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLKhachSan.DTO;
using System.Data;
using System.Data.SqlClient;

namespace QLKhachSan.DAO
{
    public class DAO_KhachHang
    {
        public static void themKhachHang(DTO_KhachHang p)
        {
            string[] name = new string[8] { "@TenKH", "@CMND", "@GioiTinh", "@DiaChi","@SDT","@QuocTich","@MaSoThue","@DiaChiThue" };
            object[] ob = new object[8] { p.TenKH, p.CMND, p.GioiTinh, p.DiaChi,p.SDT,p.QuocTich,p.MaSoThue,p.DiaChiThue };
            clsKetNoi.ThucThiLenhCoTS("pr_ThemKhachHang", name, ob, 8);
        }
        public static DataTable hienthiDanhSachKhachHang()
        {
            return clsKetNoi.Load("pr_HienThiKhachHang");
        }
        public static void suaKhachHang(DTO_KhachHang p)
        {
            string[] name = new string[9] { "@MaKH", "@TenKH", "@CMND", "@GioiTinh", "@DiaChi", "@SDT", "@QuocTich", "@MaSoThue", "@DiaChiThue" };
            object[] ob = new object[9] { p.MaKH, p.TenKH, p.CMND, p.GioiTinh, p.DiaChi, p.SDT, p.QuocTich, p.MaSoThue, p.DiaChiThue };
            clsKetNoi.ThucThiLenhCoTS("pr_SuaKhachHang", name, ob, 9);
        }
        public static void xoaKhachHang(DTO_KhachHang p)
        {
            string[] name = new string[1] { "@MKH" };
            object[] ob = new object[1] { p.MaKH };
            clsKetNoi.ThucThiLenhCoTS("pr_XoaKhachHang", name, ob, 1);
        }
        public static void suaKhachHangDeThanhToan(DTO_KhachHang p)
        {
            string[] name = new string[3] { "@MaKH", "@MaSoThue", "@DiaChiThue" };
            object[] ob = new object[3] { p.MaKH, p.MaSoThue, p.DiaChiThue };
            clsKetNoi.ThucThiLenhCoTS("pr_SuaKhachHangDeThanhToan", name, ob, 3);
        }
        
        public static DataTable hienthiDanhSachKhachHangDaThue()
        {
            return clsKetNoi.Load("pr_HienThiDanhSachKhachHangDaThue");
        }

        public static DataTable hienthiDanhSachKhachHangKhoangNgayThue(DateTime tungay, DateTime denngay)
        {
            string[] name = new string[2] { "@tungay", "@denngay" };
            object[] ob = new object[2] { tungay,denngay };
            return clsKetNoi.LoadCoTS("pr_HienThiKhachHangKhoangNgayThue",name,ob,2);
        }
    

        public static DataTable hienthiDanhSachKhachHangKhoangNgayThanhToan(DateTime tungay, DateTime denngay)
        {
            string[] name = new string[2] { "@tungay", "@denngay" };
            object[] ob = new object[2] { tungay, denngay };
            return clsKetNoi.LoadCoTS("pr_HienThiKhachHangKhoangNgayThanhToan", name, ob, 2);
        }
        public static DataTable hienthiDanhSachKhachHangTheoCMND(string so)
        {
            string[] name = new string[1] { "@CMND" };
            object[] ob = new object[1] { so};
            return clsKetNoi.LoadCoTS("pr_HienThiKhachHangTheoCMND", name, ob, 1);
        }
       
        public static DataTable hienthiDanhSachKhachHangTheoSDT(string so)
        {
            string[] name = new string[1] { "@SDT" };
            object[] ob = new object[1] { so };
            return clsKetNoi.LoadCoTS("pr_HienThiKhachHangTheoSDT", name, ob, 1);
        }
        public static DataTable hienthiDanhSachKhachHangTheoMaKH(int so)
        {
            string[] name = new string[1] { "@MaKH" };
            object[] ob = new object[1] { so };
            return clsKetNoi.LoadCoTS("pr_HienThiKhachHangTheoMaKH", name, ob, 1);
        }
        public static DataTable hienthiDanhSachKhachHangTheoMaSoThue(string so)
        {
            string[] name = new string[1] { "@MaSoThue" };
            object[] ob = new object[1] { so };
            return clsKetNoi.LoadCoTS("pr_HienThiKhachHangTheoMaSoThue", name, ob, 1);
        }
        


    }
}
